styleproperties: Implement unsetting directly
authorBenjamin Otte <otte@redhat.com>
Sat, 31 Dec 2011 21:17:25 +0000 (22:17 +0100)
committerBenjamin Otte <otte@redhat.com>
Mon, 9 Jan 2012 17:37:53 +0000 (18:37 +0100)
With subproperties, there's no need anymore for custom unset functions.

gtk/gtkstyleproperties.c

index e1913a6dd314db3bf3aa8aa75d8252d00452f181..9d26f3a1178ee021120c9802bd70dcdabe91840b 100644 (file)
@@ -886,10 +886,23 @@ gtk_style_properties_unset_property (GtkStyleProperties *props,
       g_warning ("Style property \"%s\" is not registered", property);
       return;
     }
+  if (_gtk_style_property_get_value_type (node) == G_TYPE_NONE)
+    {
+      g_warning ("Style property \"%s\" is not settable", property);
+      return;
+    }
 
-  if (node->unset_func)
+  if (GTK_IS_CSS_SHORTHAND_PROPERTY (node))
     {
-      node->unset_func (props, state);
+      GtkCssShorthandProperty *shorthand = GTK_CSS_SHORTHAND_PROPERTY (node);
+
+      for (pos = 0; pos < _gtk_css_shorthand_property_get_n_subproperties (shorthand); pos++)
+        {
+          GtkCssStyleProperty *sub = _gtk_css_shorthand_property_get_subproperty (shorthand, pos);
+          gtk_style_properties_unset_property (props,
+                                               _gtk_style_property_get_name (GTK_STYLE_PROPERTY (sub)),
+                                               state);
+        }
       return;
     }